package com.wuhan.template.module.find.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.wuhan.template.constant.Urls;
import com.wuhan.template.module.find.fragment.ZhengwuFragment;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2016/5/12.
 */
public class ZhengwuFragPagerAdapter extends FragmentStatePagerAdapter {
    private Context mContext;

    public String[] titles = {"政务要闻","城管","蔡甸","汉阳","洪山","新洲","东西湖","便民热线","天然气消息"}  ;

    public ZhengwuFragPagerAdapter(FragmentManager fm, Context context) {
        super(fm);
        this.mContext = context;
    }

    @Override
    public Fragment getItem(int position) {
        Map<String, String> params = new HashMap<>();
        switch (position) {
            case 0:
                params.put("title", "政务要闻");
                params.put("dataUrl", Urls.FIND_ZHENGWU_YAOWEN+"column_name=%E6%94%BF%E5%8A%A1%E8%A6%81%E9%97%BB");
                return ZhengwuFragment.newInstance(ZhengwuFragment.class, params);
            case 1:
                params.put("title", "城管");
                params.put("dataUrl", Urls.FIND_ZHENGWU_YAOWEN+"column_id=138&column_name=%E5%9F%8E%E7%AE%A1");
                return ZhengwuFragment.newInstance(ZhengwuFragment.class, params);

            case 2:
                params.put("title", "蔡甸");//column_id=151&column_name=%E8%94%A1%E7%94%B8
                params.put("dataUrl", Urls.FIND_ZHENGWU_YAOWEN+"column_id=151&column_name=%E8%94%A1%E7%94%B8");

                return ZhengwuFragment.newInstance(ZhengwuFragment.class, params);
            case 3:
                params.put("title", "汉阳");
                params.put("dataUrl", Urls.FIND_ZHENGWU_YAOWEN+"slide=1&num=5&column_id=152&column_name=%E6%B1%89%E9%98%B3");

                return ZhengwuFragment.newInstance(ZhengwuFragment.class, params);
            case 4:
                params.put("title", "洪山");
                params.put("dataUrl", Urls.FIND_ZHENGWU_YAOWEN+"num=5&column_id=84&column_name=%E6%B4%AA%E5%B1%B1");
                return ZhengwuFragment.newInstance(ZhengwuFragment.class, params);
            case 5:
                params.put("title", "新洲");
                params.put("dataUrl", Urls.FIND_ZHENGWU_YAOWEN+"column_id=88&column_name=%E6%96%B0%E6%B4%B2");
                return ZhengwuFragment.newInstance(ZhengwuFragment.class, params);
            case 6:
                params.put("title", "东西湖");
                params.put("dataUrl", Urls.FIND_ZHENGWU_YAOWEN+"column_id=74&column_name=%E4%B8%9C%E8%A5%BF%E6%B9%96");
                return ZhengwuFragment.newInstance(ZhengwuFragment.class, params);
            case 7:
                params.put("title", "便民热线");
                params.put("dataUrl", Urls.FIND_ZHENGWU_YAOWEN+"column_id=83&column_name=%E4%BE%BF%E6%B0%91%E7%83%AD%E7%BA%BF");
                return ZhengwuFragment.newInstance(ZhengwuFragment.class, params);
            case 8:
                params.put("title", "天然气消息");
                params.put("dataUrl", Urls.FIND_ZHENGWU_YAOWEN+"column_id=64&column_name=%E5%A4%A9%E7%84%B6%E6%B0%94%E6%B6%88%E6%81%AF");
                return ZhengwuFragment.newInstance(ZhengwuFragment.class, params);
            default:
                break;
        }
        return ZhengwuFragment.instantiate(mContext, "政务要闻");
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
       // container.removeView((View) object);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }

    @Override
    public int getCount() {
        return 9;
    }
}
